package org.fuys.etp.repo.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;

/**
 * 弹性线程池基本配置
 * @TableName etp_base_config
 */
@TableName(value ="etp_base_config")
@Data
public class EtpBaseConfig implements Serializable {
    /**
     * 配置版本 主键自增 根据version来切换版本
     */
    @TableId(type = IdType.AUTO)
    private Integer version;

    /**
     * 核心线程数
     */
    private Integer poolCoreSize;

    /**
     * 最大线程数
     */
    private Integer poolMaxSize;

    /**
     * 线程空闲时间
     */
    private Integer poolKeepAliveTime;

    /**
     * 线程空闲时间单位 默认为分钟
     */
    private Object poolAliveTimeUnit;

    /**
     * 队列大小
     */
    private Integer workQueueSize;

    /**
     * 负载检测间隔时间
     */
    private Integer selfCheckInterval;

    /**
     * 负载检测间隔时间单位 默认为分钟
     */
    private Object selfCheckIntervalUnit;

    /**
     * 拒绝策略处理类的Bean名称
     */
    private String rejectHandleBean;

    private Integer rejectCheckThreshold;

    private Integer rejectAlertThreshold;

    /**
     * cpu占用率限制
     */
    private Integer cpuPointLimit;

    /**
     * 内存占用率限制
     */
    private Integer memoryPointLimit;

    /**
     * 配置描述
     */
    private String description;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        EtpBaseConfig other = (EtpBaseConfig) that;
        return (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion()))
            && (this.getPoolCoreSize() == null ? other.getPoolCoreSize() == null : this.getPoolCoreSize().equals(other.getPoolCoreSize()))
            && (this.getPoolMaxSize() == null ? other.getPoolMaxSize() == null : this.getPoolMaxSize().equals(other.getPoolMaxSize()))
            && (this.getPoolKeepAliveTime() == null ? other.getPoolKeepAliveTime() == null : this.getPoolKeepAliveTime().equals(other.getPoolKeepAliveTime()))
            && (this.getPoolAliveTimeUnit() == null ? other.getPoolAliveTimeUnit() == null : this.getPoolAliveTimeUnit().equals(other.getPoolAliveTimeUnit()))
            && (this.getWorkQueueSize() == null ? other.getWorkQueueSize() == null : this.getWorkQueueSize().equals(other.getWorkQueueSize()))
            && (this.getSelfCheckInterval() == null ? other.getSelfCheckInterval() == null : this.getSelfCheckInterval().equals(other.getSelfCheckInterval()))
            && (this.getSelfCheckIntervalUnit() == null ? other.getSelfCheckIntervalUnit() == null : this.getSelfCheckIntervalUnit().equals(other.getSelfCheckIntervalUnit()))
            && (this.getRejectHandleBean() == null ? other.getRejectHandleBean() == null : this.getRejectHandleBean().equals(other.getRejectHandleBean()))
            && (this.getCpuPointLimit() == null ? other.getCpuPointLimit() == null : this.getCpuPointLimit().equals(other.getCpuPointLimit()))
            && (this.getMemoryPointLimit() == null ? other.getMemoryPointLimit() == null : this.getMemoryPointLimit().equals(other.getMemoryPointLimit()))
            && (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode());
        result = prime * result + ((getPoolCoreSize() == null) ? 0 : getPoolCoreSize().hashCode());
        result = prime * result + ((getPoolMaxSize() == null) ? 0 : getPoolMaxSize().hashCode());
        result = prime * result + ((getPoolKeepAliveTime() == null) ? 0 : getPoolKeepAliveTime().hashCode());
        result = prime * result + ((getPoolAliveTimeUnit() == null) ? 0 : getPoolAliveTimeUnit().hashCode());
        result = prime * result + ((getWorkQueueSize() == null) ? 0 : getWorkQueueSize().hashCode());
        result = prime * result + ((getSelfCheckInterval() == null) ? 0 : getSelfCheckInterval().hashCode());
        result = prime * result + ((getSelfCheckIntervalUnit() == null) ? 0 : getSelfCheckIntervalUnit().hashCode());
        result = prime * result + ((getRejectHandleBean() == null) ? 0 : getRejectHandleBean().hashCode());
        result = prime * result + ((getCpuPointLimit() == null) ? 0 : getCpuPointLimit().hashCode());
        result = prime * result + ((getMemoryPointLimit() == null) ? 0 : getMemoryPointLimit().hashCode());
        result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", version=").append(version);
        sb.append(", poolCoreSize=").append(poolCoreSize);
        sb.append(", poolMaxSize=").append(poolMaxSize);
        sb.append(", poolKeepAliveTime=").append(poolKeepAliveTime);
        sb.append(", poolAliveTimeUnit=").append(poolAliveTimeUnit);
        sb.append(", workQueueSize=").append(workQueueSize);
        sb.append(", selfCheckInterval=").append(selfCheckInterval);
        sb.append(", selfCheckIntervalUnit=").append(selfCheckIntervalUnit);
        sb.append(", rejectHandleBean=").append(rejectHandleBean);
        sb.append(", cpuPointLimit=").append(cpuPointLimit);
        sb.append(", memoryPointLimit=").append(memoryPointLimit);
        sb.append(", description=").append(description);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}